#!/bin/bash

if [ $# -ne 2 ]; then
	echo "You must provide other two hosts."
	exit 1
fi
host1=$1
host2=$2

echo "gen keys"
ssh-keygen -b 2048 -t rsa -N '' -f ~/.ssh/id_rsa

echo "copy pub keys"
for host in $host1 $host2 'localhost'; do
	ssh-keyscan -H $host >> ~/.ssh/known_hosts
	expect ./ssh_public_key.exp $host
done

